package com.lyfx.ly.web;

import com.lyfx.ly.service.ClassCourseService;
import com.lyfx.ly.service.StudyStepService;
import com.lyfx.ly.vo.ClassItemVo;
import com.lyfx.ly.vo.StepDescVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import javax.servlet.http.HttpServletRequest;

/**
 * @author lsy
 * @create 2020-08-18-10:48
 */
@Controller
public class MyLearnController {

    @Autowired
    ClassCourseService classCourseService;
    @Autowired
    StudyStepService studyStepService;
    /**
     * 展示课程的基本信息
     */
    @GetMapping({"/mylearn/{classId}","/mylearn.html/{classId}"})
    public String mylearn(@PathVariable(value = "classId",required = true) Long classId, Model model) {
        ClassItemVo classItemVo = classCourseService.itemClass(classId);
        model.addAttribute("items",classItemVo);
        return "mylearn";
    }


    //遍历所有部门，将结果保存到request域中
    @GetMapping("/mylearn/get/{stepId}")
    public String getAllDepartment(@PathVariable("stepId") Long stepId,Model model){
        StepDescVo descVo = studyStepService.getStepContext(stepId);
        model.addAttribute("step",descVo);
        //demo是html页面的名字，department是表示你要刷新到哪个区域,th:fragment='department'
        return "mylearn::department";
    }
}
